﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DocumentMakingTools.Models
{
    /// <summary>
    /// 源文件类
    /// </summary>
    internal class SourceFileModel
    {
        /// <summary>
        /// 文件路径
        /// </summary>
        public string FilePath { get; set; }
        /// <summary>
        /// 文件大小(字节)，可能为null
        /// </summary>
        public decimal? FileSize { get; set; }
        /// <summary>
        /// 文件名
        /// </summary>
        public string FileName { get; set; }
        /// <summary>
        /// 编程语言
        /// </summary>
        public string Language
        {
            get
            {
                if (string.IsNullOrWhiteSpace(FileName))
                    return string.Empty;
                else
                {
                    var ext = Path.GetExtension(FileName)[1..];
                    return ext switch
                    {
                        "cs" => "C#",
                        "cpp" => "C++",
                        "java" => "Java",
                        "h" => "C/C++",
                        "js" => "JavaScript",
                        "py" => "Python",
                        "vue" => "Vue",
                        _ => ext.ToUpper()
                    };
                }
            }
        }
    }
}
